<template>
    <div>
        <div id="CategoryActivity"></div>
    </div>

</template>

<script>
    import {Api} from '../../../../api/index.js'
    import echarts from 'echarts'    
    export default {
        name: "category",
        data() {
            return {
                chart: null,
                opinion: [],
                opinionData: []
            }
        },
        methods:{
            selectVerificationStatistics() {
                let url = Api.countActivityWork;
                this.$http.get(url + "/1").then((res) => {
                    this.opinionData = res.data.data;
                    this.opinion = [];
                    res.data.data.map(item => {
                        this.opinion.push(item.name);

                    });
                    this.drawPie()
                });


            },
            drawPie() {
                let _this = this;
                let myChart = echarts.init(document.getElementById('CategoryActivity'));
                myChart.setOption({
                    title: {
                        text: '活动作品数量统计',
                        left: 'center',
                        top: 10,
                        textStyle: {
                            fontSize: 24,
                            fontFamily: 'Helvetica',
                            fontWeight: 400
                        }
                    },
                    tooltip: {
                        trigger: 'item',
                        formatte: '{b}: {c} ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 5,
                        top: 10,
                        data: _this.opinion
                    },
                    series: [
                        {
                            name: '活动作品数量统计',
                            type: 'pie',
                            radius: ['0', '70%'],
                            center: ['50%', '60%'],
                            avoidLabelOverlap: false,
                            label: {
                                emphasis: {
                                    show: true,
                                    textStyle: {
                                        fontSize: '24',
                                        fontWeight: 'bold'
                                    }
                                }
                            },
                            labelLine: {
                                normal: {
                                    show: false
                                }
                            },
                            data: _this.opinionData,
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffset: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                })
            },
        },
        mounted() {
            this.selectVerificationStatistics();
        }
    }
</script>

<style scoped >
    #CategoryActivity {
        position: relative;
        left: 50%;
        margin-left: -400px;
        margin-bottom: 70px;
        width: 800px;
        height: 600px;
        border-radius: 10px;
    }
</style>